package com.entrogy.service.impl;

import com.entrogy.bean.SchoolBusTeacher;
import com.entrogy.dao.SchoolBusTeacherMapper;
import com.entrogy.service.SchoolBusTeacherService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @Author 许红松
 * @date 2019/4/23 0023 下午 3:03
 * 校车管理 关联表  跟班教师 Service接口实现类
 */
@Service(value="schoolBusTeacherService")
@Transactional
public class SchoolBusTeacherServiceImpl implements SchoolBusTeacherService {


    @Autowired
    private SchoolBusTeacherMapper schoolBusTeacherMapper;//跟班教师dao接口

    /**
     *  根据busid  查询该busid 下的跟班老师集合
     * @param map(busid,school_code,teacherid)
     * @return  List
     */
    @Override
    public List<Map<String, Object>> selectSchoolTList(Map<String,Object> map) {
        return schoolBusTeacherMapper.selectSchoolTList(map);
    }


    /**
     *  新增校车跟班老师（注意：同一校车可以有多个跟班老师  同一跟班老师不能存在于多个校车）
     *  @param schoolBusTeacher
     */
    @Override
    public void insertSchoolBusTeacher(SchoolBusTeacher schoolBusTeacher) {
        schoolBusTeacherMapper.insertSchoolBusTeacher(schoolBusTeacher);
    }

    /**
     *  根据跟班老师id去查询是否已经存在该教师（由于业务关系 不存在重复 只做验证）
     * @param Teacher_id
     * @return SchoolBusTeacher
     */
    @Override
    public SchoolBusTeacher selectSchoolBusTeacherByid(@Param(value="Teacher_id")String Teacher_id) {
        return schoolBusTeacherMapper.selectSchoolBusTeacherByid(Teacher_id);
    }

    /**
     *  根据跟班老师id去修改
     * @param schoolBusTeacher
     */
    @Override
    public void updateSchoolBusTeacher(SchoolBusTeacher schoolBusTeacher) {
        schoolBusTeacherMapper.updateSchoolBusTeacher(schoolBusTeacher);
    }

    /**
     *  根据跟班老师id去删除
     * @param schoolbusTeacherId
     */
    @Override
    public int  deleteSchoolBusTeacher(@Param(value="schoolbusTeacherId") String schoolbusTeacherId) {

        return schoolBusTeacherMapper.deleteSchoolBusTeacher(schoolbusTeacherId);
    }

    /**
     *   根据关联表id查询老师 -
     * @param schoolbusTeacherId
     * @return SchoolBusTeacher
     */
    public  List<String>  selectTeacherByTid(@Param(value="schoolbusTeacherId")String schoolbusTeacherId){
        return schoolBusTeacherMapper.selectTeacherByTid(schoolbusTeacherId);
    };
}
